// pages/operat/fleedTools/antiFleeing/antiFleeing.js
const LApp = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    Code: "",
    CompanyName: "",
    ProductName: "",
    ChuKuDate: "",//出库日期
    FWSaleArea: "",//发往片区
    FWDistributor: "",//发往经销商
    Contact: "", //联系人
    Address: "", //所在地
    SaleArea: "", //所属片区
    Precinct: "",//管辖区域
    CrossArea: "", //跨区域
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  bindCode: function (e) {
    this.setData({
      Code: e.detail.value,
    });
  },
  FleeGoodsResult: function () {
    if (this.data.Code.length < 6) {
      wx.showToast({
        title: '长度必须大于6位！',
      });
      return;
    }
    var that=this;
    LApp._get({
      url: "nbapi/fleedtool/fleegoodsresult",
      data: { key: this.data.Code, userid: LApp.globalData.userInfo.UserID },
      success: function (r) {
        that.setData({
          CompanyName: r.CompanyName,
          ProductName: r.ProductName,
          ChuKuDate: r.ChuKuDate,//出库日期
          FWSaleArea: r.FWSaleArea,//发往片区
          FWDistributor: r.FWDistributor,//发往经销商
          Contact: r.Contact, //联系人
          Address: r.Address, //所在地
          SaleArea: r.SaleArea, //所属片区
          Precinct: r.Precinct,//管辖区域
          CrossArea: r.CrossArea, //跨区域
        });
      },
      fail: function (r) {
        wx.showToast({
          title: '该码不存在或未出库',
        });
        that.setData({
          CompanyName: "",
          ProductName: "",
          ChuKuDate: "",//出库日期
          FWSaleArea: "",//发往片区
          FWDistributor: "",//发往经销商
          Contact: "", //联系人
          Address: "", //所在地
          SaleArea: "", //所属片区
          Precinct: "",//管辖区域
          CrossArea: "", //跨区域
        });
        
      }
    });
  },
  saoma: function () {
    var that = this;
    wx.scanCode({
      success: function (r) {
        that.setData({
          Code: r.result,
        })
        that.FleeGoodsResult();
      }
    });
  }
})